import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;

public class StringMatchObject {


//TODO: I am sure this object doesn't have all the functions it needs yet, if you see ones it should have please add them.
	String literal;
    StringLocationObject locations;

	public StringMatchObject() {
		this.locations = new StringLocationObject();
	}

	//This constructor is really only useful for the intersection method.
	//used for merging
	public StringMatchObject( String l, StringLocationObject ll, StringLocationObject rl) {
		this.locations = new StringLocationObject();
		HashMap<String,ArrayList<Integer>> llmap = ll.getLocationMap(), rlmap = rl.getLocationMap();
		
		this.literal = l;
		if (ll != null) this.locations.getLocationMap().putAll(llmap);
		if (rl != null) this.locations.getLocationMap().putAll(rlmap);
	}

	//Copy Constructor
	public StringMatchObject( StringMatchObject t ) {
		literal = t.literal;
		locations = t.locations;
	}
	
	public void addLocation(String filename, Integer i) {
		locations.addLocation(filename, i);
	}

    public void addLocations(StringLocationObject l){
        locations.addLocations(l);
    }
	
	public StringLocationObject getLocations() {
		return locations;
	}

	public void setLocation(StringLocationObject l) {
        locations = l;
	}

	public String getLiteral() {
		return literal;
	}

	public void setLiteral(String literal) {
		this.literal = literal;
	}
	
	public String toString() {
		return "{\"" + literal + "\"" + locations + "}";
	}
}
